Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api work #403

Merged
merged 30 commits into from
Sep 11, 2023
Merged

api work #403

merged 30 commits into from
Sep 11, 2023

Conversation

cvaroqui
Copy link
Member

@cvaroqui cvaroqui commented Sep 1, 2023

No description provided.

* GET /instance/monitor
* GET /instance/config

Use x-go-type openapi syntax to avoid a lot of transtyping code.
* Rename api.GetInstance*Element to api.Instance*Item

* Use api.InstanceStatusItem in the PostInstanceStatus handler,
  so the POST and GET /instance/status use the same body format

* Make PostInstanceStatus verify the emitter node is the
  localhost
Example:

$ curl -X GET 'https://localhost:1215/instance?path=foo001'   -H 'accept: application/json'   -H 'Authorization: Basic ..'  -k -s |jq
[
  {
    "data": {
      "config": {
        "app": "default",
        "csum": "80e572a36f85f34823211913bce56059",
        "children": [
          "foo010",
          "foo011",
          "foo012",
          "foo013",
          "foo014@dev2n1",
          "notexist"
        ],
        "orchestrate": "ha",
        "placement_policy": "last start",
        "priority": 50,
        "resources": {
          "fs#1": {
            "is_disabled": false,
            "is_monitored": false,
            "is_standby": false,
            "restart": 0,
            "restart_delay": 500000000
          },
          "volume#1": {
            "is_disabled": false,
            "is_monitored": false,
            "is_standby": false,
            "restart": 0,
            "restart_delay": 500000000
          },
          "volume#2": {
            "is_disabled": false,
            "is_monitored": false,
            "is_standby": false,
            "restart": 0,
            "restart_delay": 500000000
          },
          "volume#3": {
            "is_disabled": false,
            "is_monitored": false,
            "is_standby": false,
            "restart": 0,
            "restart_delay": 500000000
          }
        },
        "scope": [
          "dev2n1",
          "dev2n2",
          "dev2n3"
        ],
        "subsets": {},
        "topology": "failover",
        "updated_at": "2023-08-23T08:20:50.605710559+02:00"
      },
      "monitor": {
        "global_expect": "none",
        "global_expect_updated_at": "0001-01-01T00:00:00Z",
        "global_expect_options": null,
        "is_leader": false,
        "is_ha_leader": false,
        "local_expect": "started",
        "local_expect_updated_at": "2023-09-02T10:55:54.246600548+02:00",
        "orchestration_id": "00000000-0000-0000-0000-000000000000",
        "orchestration_is_done": false,
        "session_id": "00000000-0000-0000-0000-000000000000",
        "state": "idle",
        "state_updated_at": "2023-09-02T10:55:51.397889345+02:00",
        "monitor_action_executed_at": "0001-01-01T00:00:00Z",
        "preserved": false,
        "resources": {
          "fs#1": {
            "restart": {
              "remaining": 0,
              "last_at": "0001-01-01T00:00:00Z"
            }
          },
          "volume#1": {
            "restart": {
              "remaining": 0,
              "last_at": "0001-01-01T00:00:00Z"
            }
          },
          "volume#2": {
            "restart": {
              "remaining": 0,
              "last_at": "0001-01-01T00:00:00Z"
            }
          },
          "volume#3": {
            "restart": {
              "remaining": 0,
              "last_at": "0001-01-01T00:00:00Z"
            }
          }
        },
        "updated_at": "2023-09-02T10:55:54.246628287+02:00",
        "children": {
          "foo010": "up",
          "foo011": "up",
          "foo012": "undef",
          "foo013": "up",
          "foo014@dev2n1": "up",
          "notexist": "undef"
        }
      },
      "status": {
        "avail": "up",
        "frozen_at": "0001-01-01T00:00:00Z",
        "last_started_at": "2023-08-25T19:35:47.633870082+02:00",
        "overall": "up",
        "provisioned": "true",
        "resources": [
          {
            "rid": "volume#1",
            "label": "foo001-vol-1",
            "status": "up",
            "type": "volume",
            "provisioned": {
              "mtime": "2023-07-06T10:03:25.231284828+02:00",
              "state": "true"
            }
          },
          {
            "rid": "volume#2",
            "label": "foo001-vol-2",
            "status": "up",
            "type": "volume",
            "provisioned": {
              "mtime": "2023-07-06T10:03:30.127315837+02:00",
              "state": "true"
            }
          },
          {
            "rid": "volume#3",
            "label": "foo001-vol-3",
            "status": "up",
            "type": "volume",
            "provisioned": {
              "mtime": "2023-07-06T10:03:35.211348039+02:00",
              "state": "true"
            }
          },
          {
            "rid": "fs#1",
            "label": "flag /dev/shm/opensvc/svc/foo001/fs#1.flag",
            "status": "up",
            "type": "fs.flag",
            "provisioned": {
              "mtime": "2023-07-06T10:03:35.543350141+02:00",
              "state": "true"
            }
          }
        ],
        "updated_at": "2023-09-02T10:55:51.574173407+02:00"
      }
    },
    "meta": {
      "node": "dev2n1",
      "object": "foo001"
    }
  },
...
Use POST /objet/action/<action> instead, in the objectaction
package.
And drop the POST /object/abort handler.
GET /node
GET /node/config
GET /node/status
GET /node/monitor

These handlers return list of meta+data items, suited for
filtered by meta tabular outputs.
* POST /cluster/action/abort
* POST /cluster/action/freeze
* POST /cluster/action/unfreeze
As "cluster freeze" and "cluster unfreeze" are the command to
submit an orchestration, the orchestration abort must be in the
same command subsystem.
Set LocalExpect instead of State to "drained".
Example:

root@dev2n1:~/dev/om3# ./om3 "test/**" instance ls
OBJ           NODE   AVAIL
test/svc/svc1 dev2n1 n/a
test/cfg/cfg1 dev2n1 n/a
test/cfg/cfg1 dev2n3 n/a
test/cfg/cfg1 dev2n2 n/a

Also add support for adding columns to a default columning.

Example:

root@dev2n1:~/dev/om3# ./om3 "test/**" instance ls -o "+OVERALL:.data.status.overall"
OBJ           NODE   AVAIL OVERALL
test/cfg/cfg1 dev2n2 n/a   n/a
test/cfg/cfg1 dev2n1 n/a   n/a
test/svc/svc1 dev2n1 n/a   n/a
test/cfg/cfg1 dev2n3 n/a   n/a

This patch also rename the output.Renderer.Format field to
output.Renderer.Output for alignment with the commandline --output.
* instance config ls
* instance monitor ls
* instance status ls

In addition to instance ls that reports all of the above info.
So the rid is not embeded in rcfg, rstat and rmon
So the Status word is free to be used as a type.
* ExposedStatus => Status
* GetExposedStatus => GetStatus
* exposedStatusInfo => getStatusInfo
* exposedStatusInfoSched => getStatusInfoSched
And convert the "ls" command to use that.

Also,
* Fix the yaml properties stripped from their underscore.
* Rename the drbd allocation ExpireAt to ExpiredAt
* GET /resource
* GET /resource/config
* GET /resource/monitor
* GET /resource/status
* resource ls
* resource config ls
* resource monitor ls
* resource status ls
Report the error in the table cell and continue, so the user can
easily see which part of the columning syntax is wrong.
@cvaroqui cvaroqui merged commit 4becb59 into opensvc:main Sep 11, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant